package org.xs.web.http;

import org.xs.web.http.provider.HTTPHeader;
import org.xs.web.http.provider.HTTPResponse;

public class NotfoundResponse implements XSResponse{
	private String text;
	private String template;
	private int code;
	private HTTPHeader[] headers;
	
	public NotfoundResponse(boolean isTemplate,String text,int code,HTTPHeader[] headers){
		this.text = text;
		this.code = code;
		this.headers = headers;
	}
	
	 
	public NotfoundResponse(boolean isTemplate,String text,HTTPHeader[] headers){
		this(isTemplate,text,404,headers);
	}
	
	public NotfoundResponse(String text,HTTPHeader[] headers){
		this(false,text,404,headers);
	}
	
	public NotfoundResponse(String text){
		this(false,text,404,new HTTPHeader[0]);
	}
	
	public NotfoundResponse(boolean isTemplate,String text){
		this(isTemplate,text,404,new HTTPHeader[0]);
	}
	
	
	@Override
	public int getCode() {
		return code;
	}

	@Override
	public String getContentType() {
		return null;
	}

	@Override
	public HTTPHeader[] getHeaders() {
		return headers;
	}

	@Override
	public boolean isJs() {
		return false;
	}

	@Override
	public boolean isStream() {
		return false;
	}

	@Override
	public boolean isTemplete() {
		return false;
	}

	@Override
	public boolean isText() {
		return true;
	}

	@Override
	public boolean isXml() {
		return false;
	}
	@Override
	public Object apply(HTTPResponse response) {
		if(isTemplete()){
			new HtmlResponse(text, 404,headers).apply(response);
		}else{
			new PanilTextResponse(text,404,headers).apply(response);
		}
		return true;
	}

}
